//
//  test1AppDelegate.cpp
//  test1
//
//  Created by loading on 13-9-13.
//  Copyright __MyCompanyName__ 2013年. All rights reserved.
//

#include "AppDelegate.h"

#include "cocos2d.h"
#include "SimpleAudioEngine.h"
#include "MenuScene.h"
#include "HelloWorldScene.h"
#include "game/HeadIcon.h"
#include "ComView.h"

USING_NS_CC;
using namespace CocosDenshion;

AppDelegate::AppDelegate()
{

}



TPanelItem* AppDelegate::createUI(const string& name){
    if(name=="view:RoleHead"){
        return  HeadIcon::create();
    }else if(name=="view:SelectPokePanel"){
        return  SelectPockPanel::create();
    }
    return NULL;
} 

AppDelegate::~AppDelegate()
{
}

bool AppDelegate::applicationDidFinishLaunching()
{ 
    CCDirector *pDirector = CCDirector::sharedDirector();
    pDirector->setOpenGLView(CCEGLView::sharedOpenGLView());
    
    TUI::sharedDirector()->setExpand(this);
    
    DevUtils::sharedDevUtils()->setMinSize(1024, 768);
    pDirector->setDisplayStats(false); 
    pDirector->setAnimationInterval(1.0 / 60); 
     CCScene *pScene = DDZRoom::scene();
    pDirector->runWithScene(pScene);
 
    return true;
}

void AppDelegate::applicationDidEnterBackground()
{
    CCDirector::sharedDirector()->stopAnimation();
    SimpleAudioEngine::sharedEngine()->pauseBackgroundMusic();
    SimpleAudioEngine::sharedEngine()->pauseAllEffects();
}

void AppDelegate::applicationWillEnterForeground()
{
    CCDirector::sharedDirector()->startAnimation();
    SimpleAudioEngine::sharedEngine()->resumeBackgroundMusic();
    SimpleAudioEngine::sharedEngine()->resumeAllEffects();
}
